﻿using System.Collections.Generic;
using Citi.Import.Util;
using System;
using System.Text;

namespace Citi.Import.ConsoleUI
{
    public class Test
    {
        public int Id { get; set; }
        public double Value { get; set; }
        public string Value2 { get; set; }
        public Test Test2 { get; set; }

        public static List<Definition<Test>> Definitions = new List<Definition<Test>>
            {
                new Definition<Test> {ModelProperty = x => x.Id, MaxLength = 10, Position = 0, CustomConversionMethod = ValidateValue2},
                new Definition<Test>
                    {
                        ModelProperty = x => x.Value,
                        MaxLength = 10,
                        Position = 1,
                    },
                     new Definition<Test> {ModelProperty = x => x.Test2, MaxLength = 10, Position = 2, CustomConversionMethod = ValidateValue2},
            };


        private static object ValidateValue2(ref Test model, string value, List<string> fields, ref string error, List<string> headers = null)
        {
            model.Test2 = new Test { Id = int.Parse(fields[0]), Value2 = "Fabio" };
            error = "Falhou";
            return Citi.Import.Util.Conversion.Validation.ManuallyValidated;
        }

        //private static object ValidateValue(Test model, string value, List<string> fields, string error, List<string> headers = null)
        //{
        //    if (value == "Joao")
        //    {
        //        model.Value2 = fields[1];
        //        return 1.2;
        //    }

        //    return 0;
        //}

    }
}
